//---------------------------------------------------------------------------
#ifndef uMSTaskH
#define uMSTaskH
//---------------------------------------------------------------------------
#include <mstask.h>
#include "Outils.h"
//#include <msterr.h>

//---------------------------------------------------------------------------
class PACKAGE_OUTILS CMSTask
{
  private:
    bool m_bStarted;
    bool m_bInitCOM;
    bool m_bInstTask;
    ITaskScheduler *m_pITS;

    bool __fastcall StartService( void);
    bool __fastcall InitTaskScheduler( void);

    bool __fastcall GetInitialized( void) const;

  public :
    __fastcall  CMSTask( void);
    __fastcall ~CMSTask( void);

    bool __fastcall EnumTasks( TStrings *pTasksName);
    bool __fastcall GetNextRunTime( const AnsiString &strTaskName, TDateTime &dtRunTime);
    bool __fastcall GetMostRecentRunTime( const AnsiString &strTaskName, TDateTime &dtRunTime);
    bool __fastcall CreateTask( const AnsiString &strName, const AnsiString &strAppName, const AnsiString &strParameters, const AnsiString &strWorkDir, const AnsiString &strComment);
    bool __fastcall DeleteTask( const AnsiString &strTaskName);
    bool __fastcall DisplayTaskSchedulePage( const AnsiString &strTaskName);
    bool __fastcall Run( const AnsiString &strTaskName);

    AnsiString __fastcall GetPlanningString( const AnsiString &strTaskName) const;
    AnsiString __fastcall GetComment( const AnsiString &strTaskName) const;
    AnsiString __fastcall GetParameters( const AnsiString &strTaskName) const;

    bool __fastcall SetParameters( const AnsiString &strTaskName, const AnsiString &strParameters);
    bool __fastcall SetWorkingDirectory( const AnsiString &strTaskName, const AnsiString &strWorkDir);

    __property bool ServiceStarted = { read=m_bStarted };
    __property bool Initialized    = { read=GetInitialized };
};
//---------------------------------------------------------------------------
#endif
